/*
 * Lab5C.cpp
 *
 *  Created on: Mar 3, 2013
 *      Author: Anthony Varghese
 *  Description: Basic File I/O
 */
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
	cout << "Part I: basic file output" << endl;

	char filename[] = "xyz.out";
	cout << " Writing to file: " << filename << " . . . ";

	ofstream output( filename , ios::out );
	for (int i=0; i< 10; i++)
		output << i << endl;
	output.close();

	cout << "done!" << endl;

	cout <<endl << endl;
	cout << "Part II: basic file input" << endl;
	cout << " Reading from file: " << filename << " . . . " << endl;

	ifstream input( filename, ios::in );
	int indata;
	input >> indata;
	cout << "1: " << indata << endl;
	input >> indata;
	cout << "2: " << indata << endl;

	string s;
	input >> s;
	cout << "3: " << s << endl;

	while (getline(input, s))
		cout << " : " << s << endl;
	input.close();
}



